package com.com.lagou.task13;

import java.util.ListIterator;
import java.util.ArrayList;
import java.util.List;

public class WorkerTest {
    public static void main(String[] args) {
        List list = new ArrayList();
        Worker w1 = new Worker("凤姐", 18, 20000);
        Worker w2 = new Worker("欧阳峰", 60, 8000);
        Worker w3 = new Worker("刘德华", 40, 30000);
        list.add(w1);
        list.add(w2);
        list.add(w3);

        ListIterator lit = list.listIterator();

//                while (lit.hasNext()) {
//                        //Worker w = (Worker) lit.next();
//                        System.out.println(lit.next());
//                }
        //(4)在"欧阳峰"之前插入一个员工，信息为：姓名："张柏芝"，年龄：35，工资3300
        while (lit.hasNext()) {
            System.out.println(lit.next());
        }
        while (lit.hasPrevious()){
            //Object object = (Object) lit.next();
            //Worker w = (Worker) lit.previous();
            if (w2.equals(lit.previous())) {
                lit.add( new Worker("张柏芝", 35, 3300));
//                                /*int i = lit.previousIndex();
//                                list.get(i);*/
                System.out.println(lit.previous());
                //
            }


            //}
//                        for (int i = 0; i < list.size(); i++) {
//                                System.out.println(list.get(i));
//                }

        }
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }
    }
}

